import { UserProfilesAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: '',
            coin: '',
            headImg: require('@/assets/img/jingpin.png')
        },
        cartTotal: ''
    },
    mutations: {
        changeuserInfo(state, payload) {
            state.userInfo = payload.userInfo;
            state.cartTotal = payload.cartTotal;
        },
        initUserInfo(state) {
            state.userInfo = {
                nickName: '',
                coin: '',
                headImg: require('@/assets/img/jingpin.png')
            },
                state.cartTotal = ''
        }
    },
    actions: {
        async asyncchangeuserInfo({ commit }) {
            let user = await UserProfilesAPI()
            commit("changeuserInfo", user.data)
        }
    }
}